<?php echo $this->Html->script(array('print')); ?>
<style>
    #element_to_pop_up { 
        background-color:#fff;
        box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.298);
        border-radius:5px;
        color:#000;
        display:none; 
        padding:20px;
        min-width:400px;
        min-height: 180px;
    }
    .b-close{
        cursor:pointer;
        position:absolute;
        right:10px;
        top:5px;            
    }    
</style>
<div class="widget">
    <div class="whead"><h6>NOTA DE VENTA</h6><div class="clear"></div></div>
    <fieldset>
        <div id="areaImprimir">
            <table cellpadding="0" cellspacing="0" width="100%" class="tLight noBorderT">          
                <tr>                    
                    <td colspan="4"><h2><strong class="green">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GENERAL <br>INTERNACIONAL</br></strong></td>
                    <td><h2><strong class="red">NOTA DE VENTA</strong></h2></td>
                    <td><strong>FECHA : </strong><?php $fecha=explode('-',$entrega[0]['Notaventa']['fecha']); echo $fecha[2].'-'.$fecha[1].'-'.$fecha[0];?></span><br>
    <strong class="red"><br>Nro.</br></strong><?php echo $entrega[0]['Notaventa']['numero']?></td>
                </tr>                
            </table>
            <table cellpadding="0" cellspacing="0" width="100%" class="tLight noBorderT">
                <tr>
                    <td><strong>CLIENTE:</strong><?php echo $entrega[0]['Notaventa']['comprador'];?></td>
                    <td></td>
                </tr>                                              
            </table>
            <table cellpadding="0" cellspacing="0" width="100%" class="tDark">           
            <thead>
                        <tr>
                            <td width="10%">Cantidad</td>
                            <td width="10%">Tipo</td>
                            <td width="20%">Detalle</td>
                            <td width="20%">Detalle tipo</td>
                            <td width="15%">Tamano</td>
                            <td width="15%">Peso</td>
                            <td width="15%">Precio</td>
                        </tr>
            </thead>
    <?php $total=0; foreach($entrega[0]['Venta'] as $entregas):?>
                   
                        <tr>    
                            <td><?php echo $entregas['cantidad'];?></td>
                            <td><?php echo $entregas['tipo'];?></td>
                            <td><?php echo $entregas['detalle'];?></td>
                            <td><?php echo $entregas['tipo1'];?></td>
                            <td><?php echo $entregas['tamano'];?></td>
                            <td><?php echo $entregas['peso'];?></td>
                            <td><?php echo $entregas['precio'];?> Bs.</td>
                            <?php $total=$total+$entregas['precio'];?>
                        </tr>
                        <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><strong>Total</strong></td>
                        <td><span style="font-size:15px; font-weight:bold;"><?php echo $total;?> Bs.</span></td>
                        </tr>
                    
    <?php endforeach; ?>
                

                  
                    <tr>
                        <td colspan="4"><span><strong>Entregado Por : </strong></span></td>
                        <td colspan="4"></td>
                    </tr>   

            </table>
        </div>   
    </fieldset>
</div>
<br></br>
<div>
<div style="float: left; margin-left:50px;">
    <?php echo $this->Html->link('ATRAS', array('controller' => 'Ventas', 'action' => 'index'), array('class' => 'buttonS bGreen')); ?>
</div>
<div>
  <a href="#" id="btnImprimir">IMPRIMIR</a>
</div>
<div class="clear"> </div>
</div>



<script>
    $(document).ready(function() {
        $("#btnImprimir").click(function() {
            //console.log('click');
            printElem({leaveOpen: true, printMode: 'popup'});
            //printElem({ overrideElementCSS: ['http://www.imprenta.com/css/printable.css'] });
        });

        // Binding a click event
        // From jQuery v.1.7.0 use .on() instead of .bind()
        $('#my-button').bind('click', function(e) {

            // Prevents the default action to be triggered. 
            e.preventDefault();

            // Triggering bPopup when click event is fired
            $('#element_to_pop_up').bPopup({
                fadeSpeed: 'slow', //can be a string ('slow'/'fast') or int
                followSpeed: 1500, //can be a string ('slow'/'fast') or int  
                contentContainer: '.content',
                loadUrl: '<?php echo $this->Html->url(array('controller' => 'Trabajos', 'action' => 'hojarutaimprime', '1360', 'conproduccion')); ?>' //Uses jQuery.load()
            });

        });

    });
    function printElem(options) {
        $('#areaImprimir').printElement(options);
    }
</script>